package pkmn.util;

import java.util.Random;
import java.util.UUID;

public class Util {
    /**
     * Return the maximum value of parameters
     */
    public static int max (int x, int y){
        return (x > y ? x : y);
    }

    /**
     * Return the maximum value of parameters
     */
    public static double max (double x, double y){
        return (x > y ? x : y);
    }

    /**
     * Return the minimum value of parameters
     */
    public static int min (int x, int y){
        return (x < y ? x : y);
    }

    /**
     * Return the minimum value of parameters
     */
    public static double min (double x, double y){
        return (x < y ? x : y);
    }

    /**
     * Generate a number between 0.85 and 1.00
     */
    public static double factor(){
        return (new Random().nextInt(16) + 85) / 100.0;
    }


    /**
     * "percent" % of chance to return true
     */
    public static boolean probability(double percent){
        return (new Random().nextInt(1000) / 10.0) + 1.0 <= percent;
    }

    /**
     *
     */
    public static double criticalRate(int criticalLevel){
        switch(criticalLevel){
            case 1:
                return 6.25;
            case 2:
                return 12.5;
            case 3:
                return 25.0;
            case 4:
                return 33.3;
            case 5:
                return 50.0;
            case 6:
                return 100.0;
            default:
                return 6.25;
        }
    }

    public static String generateId(){
        return UUID.randomUUID().toString().substring(24);
    }
    
    public static void printAndWait(String s){
        System.out.println(s);
        try {
            Thread.sleep(1500);
        } catch (Exception e){}
    }

    public static String nvl(String first, String last){
        return first == null ? last : first;
    }
}
